1 00:00:00,530 --> 00:00:03,850 Today we're going to handle the condition where we have a blocked path. 2 00:00:03,860 --> 00:00:06,380 So our eye guy starts down a path. 3 00:00:06,380 --> 00:00:08,480 We computed our async and our path finding. 4 00:00:08,480 --> 00:00:12,520 We have a path or going to the goal, boom, something happens, gets in the way. 5 00:00:12,530 --> 00:00:13,960 Can we recover? 6 00:00:13,970 --> 00:00:15,650 I thought that would be pretty useful. 7 00:00:15,650 --> 00:00:17,390 Let's go ahead and get started. 8 00:00:18,490 --> 00:00:18,730 All right. 9 00:00:18,730 --> 00:00:22,530 So in order to handle a blocked path, we've got to create a blockage. 10 00:00:22,540 --> 00:00:25,050 So I'm going to grab this wall right here. 11 00:00:25,080 --> 00:00:27,910 I'll do a control D to duplicate. 12 00:00:27,910 --> 00:00:30,380 Collisions are offset, duplicated in place. 13 00:00:30,400 --> 00:00:31,990 I want to rotate that wall. 14 00:00:33,190 --> 00:00:35,260 And let me move it in place. 15 00:00:40,290 --> 00:00:41,070 That'll work. 16 00:00:41,100 --> 00:00:42,240 Let's resize it. 17 00:00:42,870 --> 00:00:45,000 Size or scale? 18 00:00:46,640 --> 00:00:49,970 Nice and let's call it blockage so that we don't lose it. 19 00:00:51,770 --> 00:00:53,480 And you could do this to your own maze. 20 00:00:53,480 --> 00:00:56,120 And it doesn't have to be exactly the same, right? 21 00:00:56,120 --> 00:01:00,880 As long as your dog can't get around it that way, it'll create a blockage. 22 00:01:00,890 --> 00:01:02,720 I'm just going to add a part. 23 00:01:03,470 --> 00:01:04,690 Let's see right here. 24 00:01:04,700 --> 00:01:06,110 This is going to be my trigger. 25 00:01:06,110 --> 00:01:09,770 So when he steps on this, I'll make it like I'll make it like, right here. 26 00:01:09,770 --> 00:01:13,010 When he steps on this, the wall is going to pop up. 27 00:01:14,170 --> 00:01:14,370 Right. 28 00:01:14,400 --> 00:01:18,030 And we could make this trigger. 29 00:01:20,400 --> 00:01:21,660 Now, it's not in the model. 30 00:01:21,660 --> 00:01:22,470 That's all right. 31 00:01:22,470 --> 00:01:29,390 I'm going to get my blockage right click, and then I'll group his model. 32 00:01:29,400 --> 00:01:30,810 I'll call this. 33 00:01:31,620 --> 00:01:33,450 I'll call the whole thing trigger. 34 00:01:34,440 --> 00:01:36,420 And let's get our. 35 00:01:37,120 --> 00:01:38,470 Part trigger. 36 00:01:38,590 --> 00:01:40,090 Drag it into our model. 37 00:01:40,090 --> 00:01:40,900 Trigger. 38 00:01:41,500 --> 00:01:41,940 There we go. 39 00:01:41,950 --> 00:01:43,720 We got our blockage in there, too. 40 00:01:43,750 --> 00:01:46,750 Let's make sure that the trigger. 41 00:01:48,100 --> 00:01:50,830 We want anchored on. 42 00:01:50,830 --> 00:01:52,090 We can turn canned Clyde off. 43 00:01:52,090 --> 00:01:53,200 So don't trip over it. 44 00:01:53,230 --> 00:01:55,110 We can make it invisible, too. 45 00:01:55,120 --> 00:01:57,410 I wouldn't make it fully invisible for testing, though. 46 00:01:57,430 --> 00:02:02,140 Maybe, like, make it 0.7 or something just so we can see that it's there and you hit it. 47 00:02:02,530 --> 00:02:04,540 All right, now I'm going to need a script. 48 00:02:04,960 --> 00:02:07,870 This plus sign on trigger on the trigger model. 49 00:02:07,960 --> 00:02:14,080 Add a script and we'll call this create block. 50 00:02:14,770 --> 00:02:19,690 All right, Let's get rid of this print statement and we'll get a variable for our trigger. 51 00:02:19,690 --> 00:02:25,960 The part we step on, trigger script, dot parent, and then down one level two trigger. 52 00:02:25,960 --> 00:02:29,260 And then we also need a variable for the blockage. 53 00:02:29,260 --> 00:02:31,120 So let me just call that wall. 54 00:02:31,120 --> 00:02:34,170 There's only one wall we're worried about, and that's the blockage wall. 55 00:02:34,180 --> 00:02:37,780 So I'll do script dot parent blockage. 56 00:02:37,780 --> 00:02:40,600 Now we need to touch the vent for the trigger. 57 00:02:40,600 --> 00:02:48,250 The trigger part right Trigger dot touched colon connect, and we'll just do an anonymous function right 58 00:02:48,250 --> 00:02:50,860 here and we'll get the other part. 59 00:02:50,860 --> 00:02:52,510 That's the part that hits the trigger. 60 00:02:53,440 --> 00:02:57,400 We're going to check to see if it is an NPC or some sort of character. 61 00:02:57,730 --> 00:03:04,350 Let's do local hume equals other part parent that would take it up to the character level. 62 00:03:04,360 --> 00:03:09,670 And now we do a fine first child to see if there is a humanoid associated with that part that hit our 63 00:03:09,670 --> 00:03:10,300 trigger. 64 00:03:10,300 --> 00:03:14,080 If there is, let's go ahead and make a blockade. 65 00:03:14,260 --> 00:03:15,190 So we'll do. 66 00:03:15,190 --> 00:03:19,120 If HUME then hit our wall. 67 00:03:19,310 --> 00:03:24,130 We'll set the transparency to zero and then we'll get the wall. 68 00:03:24,830 --> 00:03:28,180 And that can collide to true. 69 00:03:28,180 --> 00:03:32,140 Now Can collide is already true and transparency is already zero. 70 00:03:32,140 --> 00:03:33,790 We need to change that. 71 00:03:33,840 --> 00:03:35,050 We'll go ahead and copy this. 72 00:03:35,050 --> 00:03:41,980 Control C, go up here, Control V and then we're just going to when the game starts up, we're going 73 00:03:41,980 --> 00:03:45,640 to make this false, we're going to make that transparency one. 74 00:03:45,640 --> 00:03:48,000 Now it's just like it's not even there. 75 00:03:48,010 --> 00:03:49,270 Let's go ahead and play this. 76 00:03:49,270 --> 00:03:51,100 He should run right into it. 77 00:03:51,100 --> 00:03:53,560 We're just checking to see if our trigger works. 78 00:03:54,010 --> 00:03:58,030 Let's go to view output, check for any errors. 79 00:03:58,360 --> 00:03:59,500 See Slow dog. 80 00:03:59,500 --> 00:04:00,580 He starts running. 81 00:04:00,580 --> 00:04:03,310 He's like, I'll get that gold. 82 00:04:03,310 --> 00:04:04,660 This is no problem. 83 00:04:05,210 --> 00:04:05,800 Boom. 84 00:04:05,850 --> 00:04:07,030 Oh bomber. 85 00:04:07,040 --> 00:04:09,980 So he could the he did not handle the blocked path. 86 00:04:10,010 --> 00:04:13,550 Now let's add the code to slaw dog to make it so that he can. 87 00:04:15,140 --> 00:04:16,700 I'm going to turn my game off. 88 00:04:17,530 --> 00:04:18,340 Here we go. 89 00:04:18,640 --> 00:04:20,000 I close my walls. 90 00:04:20,080 --> 00:04:21,670 I look for Slow Dog. 91 00:04:21,700 --> 00:04:23,740 We call that move Npk. 92 00:04:23,770 --> 00:04:24,970 Double click that. 93 00:04:25,970 --> 00:04:29,420 And I'm going to get rid of this output window so I have a little more real estate. 94 00:04:30,300 --> 00:04:32,010 So we've got our follow the path. 95 00:04:32,010 --> 00:04:32,520 That's good. 96 00:04:32,520 --> 00:04:33,330 Move to finish. 97 00:04:33,330 --> 00:04:35,470 That's good down here. 98 00:04:35,490 --> 00:04:42,990 I am going to get the path variable that we got, the path variable we got from create path on the path 99 00:04:42,990 --> 00:04:46,830 winding and then going to do a dot blocked. 100 00:04:46,830 --> 00:04:51,750 So a blocked is an event that's fired when the path is blocked. 101 00:04:51,750 --> 00:05:00,120 So we get the blocked, we will connect that event when it gets fired to an anonymous function and we 102 00:05:00,120 --> 00:05:04,130 get a waypoint right, we get a waypoint where the blockage occurs. 103 00:05:04,140 --> 00:05:14,640 So I'll do WP for Waypoint and it will also fire a blocked event if the blockage happens behind us in 104 00:05:14,640 --> 00:05:16,710 our track or behind the NPC. 105 00:05:16,710 --> 00:05:18,780 So we don't care about that. 106 00:05:18,780 --> 00:05:20,190 It can block behind us. 107 00:05:20,190 --> 00:05:28,500 We only care about blocking in front of us, so we have to do an if statement we'll do if w p is greater 108 00:05:28,500 --> 00:05:34,440 than the w p index, then we care, right? 109 00:05:34,440 --> 00:05:37,080 So then what we're going to do is we're going to say a follow path 110 00:05:39,240 --> 00:05:40,550 treasure. 111 00:05:40,560 --> 00:05:42,900 And what that's going to do is call follow path. 112 00:05:42,900 --> 00:05:49,680 Again, we're going to recompute new wave points, we're going to recover from our blockage and that 113 00:05:49,680 --> 00:05:51,030 should do it. 114 00:05:51,090 --> 00:05:52,380 Let's try. 115 00:05:55,210 --> 00:05:56,200 Here we go. 116 00:06:00,140 --> 00:06:00,980 Come on, Sardar. 117 00:06:01,010 --> 00:06:02,000 Get that treasure. 118 00:06:06,170 --> 00:06:07,170 Oh, look at that. 119 00:06:07,250 --> 00:06:08,670 He figured it out. 120 00:06:08,690 --> 00:06:11,420 Now he's going to go all the way around. 121 00:06:12,710 --> 00:06:17,840 So I'm not going to I'm not going to make you watch all that, but you get the idea, he computed, 122 00:06:17,840 --> 00:06:19,670 and he figured out how to get around. 123 00:06:20,390 --> 00:06:21,500 That's pretty cool. 124 00:06:21,740 --> 00:06:24,710 Next video I'm going to do climbing.